# -*- coding: utf-8 -*-
# @Author  : CaoHan
# @Time    : 2024/2/5 10:52

# 2023.1.3 南京：法相直接辐射
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
plt.rc("font",family='STHeiti')
# 设置全局字体大小
plt.rcParams.update({'font.size': 14})  # 设置全局默认字体大小

P_harv_max = 80

x = []
for i in range(24):
    x.append(i * 3600)
x_data = np.array(x)
y_data = np.array(
    [3.83E-05, 3.83E-05, 3.83E-05, 3.83E-05, 3.83E-05, 3.83E-05, 3.83E-05, 44.09762981, 310.8625846, 526.693942,
     660.2906923, 732.564242, 743.4199896, 734.0439475, 626.6957254, 491.1311621, 276.6414732, 0.021078483, 3.83E-05,
     3.83E-05, 3.83E-05, 3.83E-05, 3.83E-05, 3.83E-05]) / 743.4 * P_harv_max


def getInterpFunc():
    interp_func = interp1d(x_data, y_data, kind='cubic')
    return interp_func


def plotHarvest():
    # 生成插值曲线的x值
    x_interp = np.linspace(min(x_data), max(x_data), 100)/3600
    # 计算插值曲线的y值
    y_interp = getInterpFunc()(np.linspace(min(x_data), max(x_data), 100))
    plt.plot(x_interp, y_interp, 'b', linewidth=2.5)
    plt.xlabel('时间/h')
    plt.ylabel('获取能量功率/W')
    plt.grid(True)
    plt.show()


if __name__ == "__main__":
    plotHarvest()
